package com.example.myapplication.tack_18;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.Toast;

import com.example.myapplication.R;

import static com.example.myapplication.utils.OkHttpTool.init;

public class ManageActivity extends AppCompatActivity {
    private ImageView exit;
    private EditText plateNo;
    private EditText VIN;
    private EditText kilometers;
    private EditText phone;
    private String[] starArray = {"大型汽车", "小型汽车", "大型新能源汽车","小型新能源汽车","普通摩托车","...."};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tack_18_activity_manage);
        init();
        exit_();
        initSpinner();
        getVehicle();
    }

    private void getVehicle() {
        String plateNo_ = plateNo.getText().toString();
        String VIN_ = VIN.getText().toString();
        String kilometers_ = kilometers.getText().toString();
        String phone_ = phone.getText().toString();
    }

    private void exit_() {
        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ManageActivity.this.finish();
            }
        });
    }
    private void initSpinner() {
        //声明一个下拉列表的数组适配器
        ArrayAdapter<String> starAdapter = new ArrayAdapter<String>(this, R.layout.item_select, starArray);
        //设置数组适配器的布局样式
        starAdapter.setDropDownViewResource(R.layout.tack_18_item_dropdown);
        //从布局文件中获取名叫sp_dialog的下拉框
        Spinner sp = findViewById(R.id.spinner);
        //设置下拉框的标题，不设置就没有难看的标题了
        sp.setPrompt("车辆类型");
        //设置下拉框的数组适配器
        sp.setAdapter(starAdapter);
        //设置下拉框默认的显示第一项
        sp.setSelection(0);
        //给下拉框设置选择监听器，一旦用户选中某一项，就触发监听器的onItemSelected方法
        sp.setOnItemSelectedListener(new MySelectedListener());
    }

    class MySelectedListener implements AdapterView.OnItemSelectedListener {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
//            Toast.makeText(ManageActivity.this,"你的选择是"+starArray[i],Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    }
    private void init() {
        exit = findViewById(R.id.exit);
        plateNo = findViewById(R.id.plateNo);
        VIN = findViewById(R.id.VIN);
        kilometers = findViewById(R.id.kilometers);
        phone = findViewById(R.id.phone);
    }
}